/**
 * Created by CK on 2016/8/2.
 */

$(document).ready(function(){
    var options = {
        html: true,
        placement: 'bottom-left',
        animation: 'pop',
        width: 350,
        height: 200,
        closable: true,
        padding: true,
        delay: 300,
        title: '查看人员',
        content: '<div class="peopleInfo">信息读取中，请稍后...</div>',
        trigger: 'click'
    };
    /**
     * 点击按钮后显示div，再判断对应div是否已经加载数据，
     * 无则去后台读取出数据，显示到div中
     */
    $('.survey-question table a').webuiPopover(options).click(function(){
        var target = $(this);
        target.webuiPopover('show');
        if($('#' + target.attr('data-target')).find('.peopleInfo table').length > 0) return false;
        $.post('askSurveyOptionPeople', {type: target.attr('qtype'), info:target.attr('qinfo')}, function(tableHtml){
            $('#' + target.attr('data-target')).find('.peopleInfo').html(tableHtml);
        });
    });
    //导出
    $('#bt_export').click(function() {
        window.top.swal({
            title: '选择导出模板',
            type: 'info',
            input: 'select',
            inputOptions: {
                1: '模板1',
                2: '模板2'
            },
            showConfirmButton: true,
            showCancelButton: true,
            cancelButtonText: '取消',
            confirmButtonText: '导出',
            showLoaderOnConfirm: true
        }).then(function (type) {
            window.location.href = baseUrl + 'Ask/exportSurveyStats?surveyId=' + xhTool.getQuery('iASId') + '&type=' + type;
        });

    });
});
///**
// * 查看选择题的选项选择人员
// * '_'前为问卷ID，后为选项ID
// */
//function showOptionPeople(param){
//    var paramArr = param.split('_');
//    var src = baseUrl + 'Ask/askSurveyOptionPeople?iASId='+ paramArr[0] +'&iAQId='+ paramArr[1] +'&iAOId='+ paramArr[2];
//    window.top.createModal(
//        '<iframe src="'+ src +'" frameborder="0" style="width: 100%;height: 600px;"></iframe>',
//        '查看选择人员', '', 'md'
//    );
//}
///**
// * 查看文本题的答题人员
// * '_'前为问卷ID，后为其中一个答案ID
// * 根据答案ID找出用户输入信息后，使用问卷ID和输入信息查询输入同样信息的用户
// */
//function showAnswerPeople(param){
//    var paramArr = param.split('_');
//    var src = baseUrl + 'Ask/askSurveyOptionPeople?iASId='+ paramArr[0] +'&iAQId='+ paramArr[1] +'&iAAId='+ paramArr[2];
//    window.top.createModal(
//        '<iframe src="'+ src +'" frameborder="0" style="width: 100%;height: 600px;"></iframe>',
//        '查看选择人员', '', 'md'
//    );
//}